package WeiQi;

import java.awt.*;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

public class ChessPoint_black extends Panel implements MouseListener {
    ChessPad cp = null;
    ChessPoint_black(ChessPad cp) {
        this.cp = cp;
        addMouseListener(this);				// 注册鼠标侦听器
    }
    // 设置黑棋子的颜色、位置和大小
    public void paint(Graphics g) {
        g.setColor(Color.black);
        g.fillOval(0, 0, 14, 14);
    }
    // 实现鼠标按下方法，当右击棋子时，从棋盘中去掉该棋子（悔子）
    public void mousePressed(MouseEvent e) {
        if (e.getModifiersEx() == InputEvent.BUTTON3_DOWN_MASK) {
            cp.remove(this);
            cp.chessmancolor = 1;
            cp.text_2.setText("");
            cp.text_1.setText("请黑棋下子");
        }
    }
    // 当双击棋子时，则吃掉当前棋子（吃子）
    public void mouseClicked(MouseEvent e) {
        if (e.getClickCount() >= 2)
            cp.remove(this);
    }
    public void mouseEntered(MouseEvent e) {
    }
    public void mouseExited(MouseEvent e) {
    }
    public void mouseReleased(MouseEvent e) {
    }
}


